```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Zookeeper Leader选举机制详解</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            color: #2d3748;
            line-height: 1.6;
        }
        .hero-gradient {
            background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
        }
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
        }
        .highlight-box {
            border-left: 4px solid #3b82f6;
            background-color: #f8fafc;
        }
        .dropcap:first-letter {
            float: left;
            font-size: 4.5rem;
            line-height: 0.65;
            margin: 0.1em 0.15em 0 0;
            font-weight: 700;
            color: #1e3a8a;
        }
    </style>
</head>
<body class="bg-gray-50">
    <!-- Hero Section -->
    <header class="hero-gradient text-white py-20 px-4 lg:px-0">
        <div class="container mx-auto max-w-5xl">
            <div class="flex flex-col lg:flex-row items-center">
                <div class="lg:w-1/2 mb-10 lg:mb-0 lg:pr-10">
                    <h1 class="text-4xl md:text-5xl font-bold mb-4 font-serif">Zookeeper Leader选举机制</h1>
                    <p class="text-xl opacity-90 mb-6">分布式系统中实现高可用性与一致性的核心机制</p>
                    <div class="flex items-center">
                        <div class="w-12 h-12 rounded-full bg-blue-400 flex items-center justify-center mr-4">
                            <i class="fas fa-server text-white text-xl"></i>
                        </div>
                        <div>
                            <p class="font-medium">分布式系统关键组件</p>
                            <p class="text-sm opacity-80">确保集群高可用性</p>
                        </div>
                    </div>
                </div>
                <div class="lg:w-1/2">
                    <div class="bg-white bg-opacity-10 p-8 rounded-xl border border-white border-opacity-20 backdrop-filter backdrop-blur-sm">
                        <div class="mermaid">
                            graph TD
                                A[集群启动] --> B[初始化状态]
                                B --> C[选举候选阶段]
                                C --> D[节点投票]
                                D --> E{获得多数票?}
                                E -->|是| F[成为Leader]
                                E -->|否| D
                                F --> G[数据同步]
                                G --> H[正常运行]
                                H --> I{Leader故障?}
                                I -->|是| C
                                I -->|否| H
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </header>

    <!-- Main Content -->
    <main class="container mx-auto max-w-5xl px-4 py-16">
        <!-- Introduction Section -->
        <section class="mb-20">
            <div class="dropcap text-lg leading-relaxed text-gray-700">
                Zookeeper 的 Leader 选举是一个关键的机制，用于确保在分布式环境中只有一个节点被选为 Leader，以协调和管理集群中的重要任务。这个过程的设计目标是实现高可用性、故障恢复和一致性。以下是 Zookeeper Leader 选举过程的详细解析：
            </div>
        </section>

        <!-- Background Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                    <i class="fas fa-info-circle text-blue-600"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800 font-serif">背景与前提</h2>
            </div>
            <div class="grid md:grid-cols-2 gap-8">
                <div class="bg-white rounded-xl shadow-md p-6 card-hover transition-all duration-300">
                    <h3 class="text-lg font-semibold mb-3 text-blue-700">集群组成</h3>
                    <p class="text-gray-700">Zookeeper 集群（称为 Zookeeper Ensemble）由多个节点组成，这些节点称为服务器。集群中的节点被分为 Leader、Follower 和 Observer 三种角色。</p>
                    <div class="mt-4 flex justify-center">
                        <div class="mermaid w-full">
                            pie
                                title 节点角色分布
                                "Leader" : 1
                                "Follower" : 3
                                "Observer" : 2
                        </div>
                    </div>
                </div>
                <div class="bg-white rounded-xl shadow-md p-6 card-hover transition-all duration-300">
                    <h3 class="text-lg font-semibold mb-3 text-blue-700">角色职责</h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <span class="text-blue-500 mr-2"><i class="fas fa-crown"></i></span>
                            <span><strong>Leader</strong> - 负责处理写操作和协调事务</span>
                        </li>
                        <li class="flex items-start">
                            <span class="text-blue-500 mr-2"><i class="fas fa-users"></i></span>
                            <span><strong>Follower</strong> - 处理读请求和参与选举过程</span>
                        </li>
                        <li class="flex items-start">
                            <span class="text-blue-500 mr-2"><i class="fas fa-eye"></i></span>
                            <span><strong>Observer</strong> - 仅处理读请求，不参与选举</span>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Election Process Section -->
        <section class="mb-20">
            <div class="flex items-center mb-8">
                <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-4">
                    <i class="fas fa-vote-yea text-blue-600"></i>
                </div>
                <h2 class="text-2xl font-bold text-gray-800 font-serif">选举过程概述</h2>
            </div>
            <div class="mb-8">
                <p class="text-gray-700 mb-6">选举过程是为了确保在 Zookeeper 集群中始终有一个 Leader 节点。Leader 节点是集群的主控节点，负责所有的写请求，并确保集群中的数据一致性。在集群启动或 Leader 节点失败时，必须进行 Leader 选举以选择新的 Leader。</p>
                <div class="highlight-box p-6 rounded-lg mb-6">
                    <h4 class="text-lg font-semibold text-blue-700 mb-3">关键选举原则</h4>
                    <ul class="list-disc pl-5 space-y-2">
                        <li>采用多数投票机制（Quorum）</li>
                        <li>每个节点有唯一的ID和ZXID（事务ID）</li>
                        <li>需要获得超过半数节点的投票才能成为Leader</li>
                        <li>通过